home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / crimfght.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  21KB  |  569 lines

  1. /***************************************************************************
  2.  
  3. Crime Fighters (Konami GX821) (c) 1989 Konami
  4.  
  5. Preliminary driver by:
  6.     Manuel Abadia <manu@teleline.es>
  7.  
  8. ***************************************************************************/
  9.  
  10. #include "driver.h"
  11. #include "vidhrdw/generic.h"
  12. #include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
  13. #include "vidhrdw/konamiic.h"
  14.  
  15.  
  16. /* prototypes */
  17. static void crimfght_init_machine( void );
  18. static void crimfght_banking( int lines );
  19.  
  20. void crimfght_vh_stop( void );
  21. int crimfght_vh_start( void );
  22. void crimfght_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  23.  
  24.  
  25. static WRITE_HANDLER( crimfght_coin_w )
  26. {
  27.     coin_counter_w(0,data & 1);
  28.     coin_counter_w(1,data & 2);
  29. }
  30.  
  31. static WRITE_HANDLER( crimfght_sh_irqtrigger_w )
  32. {
  33.     soundlatch_w(offset,data);
  34.     cpu_cause_interrupt(1,0xff);
  35. }
  36.  
  37. static WRITE_HANDLER( crimfght_snd_bankswitch_w )
  38. {
  39.     unsigned char *RAM = memory_region(REGION_SOUND1);
  40.     /* b1: bank for channel A */
  41.     /* b0: bank for channel B */
  42.  
  43.     int bank_A = 0x20000*((data >> 1) & 0x01);
  44.     int bank_B = 0x20000*((data) & 0x01);
  45.  
  46.     K007232_bankswitch(0,RAM + bank_A,RAM + bank_B);
  47. }
  48.  
  49.  
  50. /********************************************/
  51.  
  52. static READ_HANDLER( speedup_r )
  53. {
  54.     unsigned char *RAM = memory_region(REGION_CPU1);
  55.  
  56.     int data = ( RAM[0x0414] << 8 ) | RAM[0x0415];
  57.  
  58.     if ( data < memory_region_length(REGION_CPU1) )
  59.     {
  60.         data = ( RAM[data] << 8 ) | RAM[data + 1];
  61.  
  62.         if ( data == 0xffff )
  63.             cpu_spinuntil_int();
  64.     }
  65.  
  66.     return RAM[0x0414];
  67. }
  68.  
  69. static struct MemoryReadAddress crimfght_readmem[] =
  70. {
  71.     { 0x0000, 0x03ff, MRA_BANK1 },            /* banked RAM */
  72.     { 0x0414, 0x0414, speedup_r },
  73.     { 0x0400, 0x1fff, MRA_RAM },            /* RAM */
  74.     { 0x3f80, 0x3f80, input_port_7_r },        /* Coinsw */
  75.     { 0x3f81, 0x3f81, input_port_3_r },        /* 1P controls */
  76.     { 0x3f82, 0x3f82, input_port_4_r },        /* 2P controls */
  77.     { 0x3f83, 0x3f83, input_port_1_r },        /* DSW #2 */
  78.     { 0x3f84, 0x3f84, input_port_2_r },        /* DSW #3 */
  79.     { 0x3f85, 0x3f85, input_port_5_r },        /* 3P controls */
  80.     { 0x3f86, 0x3f86, input_port_6_r },        /* 4P controls */
  81.     { 0x3f87, 0x3f87, input_port_0_r },        /* DSW #1 */
  82.     { 0x3f88, 0x3f88, watchdog_reset_r },    /* watchdog reset */
  83.     { 0x2000, 0x5fff, K052109_051960_r },    /* video RAM + sprite RAM */
  84.     { 0x6000, 0x7fff, MRA_BANK2 },            /* banked ROM */
  85.     { 0x8000, 0xffff, MRA_ROM },            /* ROM */
  86.     { -1 }    /* end of table */
  87. };
  88.  
  89. static struct MemoryWriteAddress crimfght_writemem[] =
  90. {
  91.     { 0x0000, 0x03ff, MWA_BANK1 },                    /* banked RAM */
  92.     { 0x0400, 0x1fff, MWA_RAM },                    /* RAM */
  93.     { 0x3f88, 0x3f88, crimfght_coin_w },            /* coin counters */
  94.     { 0x3f8c, 0x3f8c, crimfght_sh_irqtrigger_w },    /* cause interrupt on audio CPU? */
  95.     { 0x2000, 0x5fff, K052109_051960_w },            /* video RAM + sprite RAM */
  96.     { 0x6000, 0x7fff, MWA_ROM },                    /* banked ROM */
  97.     { 0x8000, 0xffff, MWA_ROM },                    /* ROM */
  98.     { -1 }    /* end of table */
  99. };
  100.  
  101. static struct MemoryReadAddress crimfght_readmem_sound[] =
  102. {
  103.     { 0x0000, 0x7fff, MRA_ROM },                /* ROM 821l01.h4 */
  104.     { 0x8000, 0x87ff, MRA_RAM },                /* RAM */
  105.     { 0xa001, 0xa001, YM2151_status_port_0_r },    /* YM2151 */
  106.     { 0xc000, 0xc000, soundlatch_r },            /* soundlatch_r */
  107.     { 0xe000, 0xe00d, K007232_read_port_0_r },    /* 007232 registers */
  108.     { -1 }    /* end of table */
  109. };
  110.  
  111. static struct MemoryWriteAddress crimfght_writemem_sound[] =
  112. {
  113.     { 0x0000, 0x7fff, MWA_ROM },                    /* ROM 821l01.h4 */
  114.     { 0x8000, 0x87ff, MWA_RAM },                    /* RAM */
  115.     { 0xa000, 0xa000, YM2151_register_port_0_w },    /* YM2151 */
  116.     { 0xa001, 0xa001, YM2151_data_port_0_w },        /* YM2151 */
  117.     { 0xe000, 0xe00d, K007232_write_port_0_w },        /* 007232 registers */
  118.     { -1 }    /* end of table */
  119. };
  120.  
  121. /***************************************************************************
  122.  
  123.     Input Ports
  124.  
  125. ***************************************************************************/
  126.  
  127. INPUT_PORTS_START( crimfght )
  128.     PORT_START    /* DSW #1 */
  129.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coinage ) )
  130.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  131.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  132.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  133.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  134.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  135.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  136.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  137.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  138.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  139.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  140.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  141.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  142.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  143.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  144.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  145.     PORT_DIPSETTING(    0x00, "1 Coin/99 Credits" )
  146. /*    PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  147.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  148.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  149.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  150.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  151.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  152.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  153.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  154.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  155.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  156.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  157.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  158.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  159.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  160.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  161.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  162.     PORT_DIPSETTING(    0x00, "Invalid" ) */
  163.  
  164.     PORT_START    /* DSW #2 */
  165.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
  166.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  167.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  168.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  169.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  170.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  171.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
  172.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  173.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  174.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  175.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  176.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  177.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  178.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  179.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  180.     PORT_DIPNAME( 0x60, 0x40, DEF_STR( Difficulty ) )
  181.     PORT_DIPSETTING(    0x60, "Easy" )
  182.     PORT_DIPSETTING(    0x40, "Normal" )
  183.     PORT_DIPSETTING(    0x20, "Difficult" )
  184.     PORT_DIPSETTING(    0x00, "Very difficult" )
  185.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  186.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  187.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  188.  
  189.     PORT_START    /* DSW #3 */
  190.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
  191.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  192.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  193.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  194.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  195.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  196.     PORT_SERVICE( 0x04, IP_ACTIVE_HIGH )
  197.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  198.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  199.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  200.     PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
  201.  
  202.     PORT_START    /* PLAYER 1 INPUTS */
  203.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  204.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  205.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  206.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  207.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  208.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  209.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  210.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  211.  
  212.     PORT_START    /* PLAYER 2 INPUTS */
  213.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  214.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  215.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  216.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  217.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  218.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  219.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  220.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  221.  
  222.     PORT_START    /* PLAYER 3 INPUTS */
  223.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER3 )
  224.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER3 )
  225.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER3 )
  226.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER3 )
  227.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
  228.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
  229.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  230.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  231.  
  232.     PORT_START    /* PLAYER 4 INPUTS */
  233.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER4 )
  234.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER4 )
  235.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER4 )
  236.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER4 )
  237.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER4 )
  238.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER4 )
  239.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  240.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  241.  
  242.     PORT_START    /* COINSW */
  243.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  244.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  245.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
  246.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN4 )
  247.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
  248.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
  249.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE3 )
  250.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE4 )
  251. INPUT_PORTS_END
  252.  
  253. INPUT_PORTS_START( crimfgtj )
  254.     PORT_START    /* DSW #1 */
  255.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coinage ) )
  256.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  257.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  258.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  259.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  260.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  261.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  262.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  263.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  264.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  265.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  266.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  267.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  268.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  269.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  270.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  271.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  272.     PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  273.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  274.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  275.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  276.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  277.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  278.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  279.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  280.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  281.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  282.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  283.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  284.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  285.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  286.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  287.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  288. //    PORT_DIPSETTING(    0x00, "Invalid" )
  289.  
  290.     PORT_START    /* DSW #2 */
  291.     PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )
  292.     PORT_DIPSETTING(    0x03, "1" )
  293.     PORT_DIPSETTING(    0x02, "2" )
  294.     PORT_DIPSETTING(    0x01, "3" )
  295.     PORT_DIPSETTING(    0x00, "4" )
  296.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
  297.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  298.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  299.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  300.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  301.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  302.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  303.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  304.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  305.     PORT_DIPNAME( 0x60, 0x40, DEF_STR( Difficulty ) )
  306.     PORT_DIPSETTING(    0x60, "Easy" )
  307.     PORT_DIPSETTING(    0x40, "Normal" )
  308.     PORT_DIPSETTING(    0x20, "Difficult" )
  309.     PORT_DIPSETTING(    0x00, "Very difficult" )
  310.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  311.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  312.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  313.  
  314.     PORT_START    /* DSW #3 */
  315.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
  316.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  317.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  318.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  319.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  320.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  321.     PORT_SERVICE( 0x04, IP_ACTIVE_HIGH )
  322.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  323.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  324.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  325.     PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
  326.  
  327.     PORT_START    /* PLAYER 1 INPUTS */
  328.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  329.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  330.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  331.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  332.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  333.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  334.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
  335.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  336.  
  337.     PORT_START    /* PLAYER 2 INPUTS */
  338.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  339.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  340.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  341.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  342.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  343.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  344.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  345.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  346.  
  347.     PORT_START    /* PLAYER 3 INPUTS */
  348.     PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
  349.  
  350.     PORT_START    /* PLAYER 4 INPUTS */
  351.     PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
  352.  
  353.     PORT_START    /* COINSW */
  354.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  355.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  356.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  357.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  358.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN3 )
  359.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN4 )
  360.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  361.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  362. INPUT_PORTS_END
  363.  
  364.  
  365.  
  366. /***************************************************************************
  367.  
  368.     Machine Driver
  369.  
  370. ***************************************************************************/
  371.  
  372. static struct YM2151interface ym2151_interface =
  373. {
  374.     1,            /* 1 chip */
  375.     3579545,    /* 3.579545 MHz */
  376.     { YM3012_VOL(50,MIXER_PAN_LEFT,50,MIXER_PAN_RIGHT) },
  377.     { 0 },
  378.     { crimfght_snd_bankswitch_w }
  379. };
  380.  
  381. static void volume_callback(int v)
  382. {
  383.     K007232_set_volume(0,0,(v & 0x0f) * 0x11,0);
  384.     K007232_set_volume(0,1,0,(v >> 4) * 0x11);
  385. }
  386.  
  387. static struct K007232_interface k007232_interface =
  388. {
  389.     1,        /* number of chips */
  390.     { REGION_SOUND1 },    /* memory regions */
  391.     { K007232_VOL(20,MIXER_PAN_CENTER,20,MIXER_PAN_CENTER) },    /* volume */
  392.     { volume_callback }    /* external port callback */
  393. };
  394.  
  395.  
  396.  
  397. static struct MachineDriver machine_driver_crimfght =
  398. {
  399.     /* basic machine hardware */
  400.     {
  401.         {
  402.             CPU_KONAMI,
  403.             3000000,        /* ? */
  404.             crimfght_readmem,crimfght_writemem,0,0,
  405.             interrupt,1
  406.         },
  407.         {
  408.             CPU_Z80 | CPU_AUDIO_CPU,
  409.             3579545,
  410.             crimfght_readmem_sound, crimfght_writemem_sound,0,0,
  411.             ignore_interrupt,0    /* interrupts are triggered by the main CPU */
  412.         }
  413.     },
  414.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  415.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  416.     crimfght_init_machine,
  417.  
  418.     /* video hardware */
  419.     64*8, 32*8, { 13*8, (64-13)*8-1, 2*8, 30*8-1 },
  420.     0,    /* gfx decoded by konamiic.c */
  421.     512, 512,
  422.     0,
  423.  
  424.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  425.     0,
  426.     crimfght_vh_start,
  427.     crimfght_vh_stop,
  428.     crimfght_vh_screenrefresh,
  429.  
  430.     /* sound hardware */
  431.     SOUND_SUPPORTS_STEREO,0,0,0,
  432.     {
  433.         {
  434.             SOUND_YM2151,
  435.             &ym2151_interface
  436.         },
  437.         {
  438.             SOUND_K007232,
  439.             &k007232_interface,
  440.         }
  441.  
  442.     }
  443. };
  444.  
  445. /***************************************************************************
  446.  
  447.   Game ROMs
  448.  
  449. ***************************************************************************/
  450.  
  451. ROM_START( crimfght )
  452.     ROM_REGION( 0x28000, REGION_CPU1 ) /* code + banked roms */
  453.     ROM_LOAD( "821l02.f24", 0x10000, 0x18000, 0x588e7da6 )
  454.     ROM_CONTINUE(           0x08000, 0x08000 )
  455.  
  456.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the sound CPU */
  457.     ROM_LOAD( "821l01.h4",  0x0000, 0x8000, 0x0faca89e )
  458.  
  459.     ROM_REGION( 0x080000, REGION_GFX1 ) /* graphics ( don't dispose as the program can read them ) */
  460.     ROM_LOAD( "821k06.k13", 0x000000, 0x040000, 0xa1eadb24 )    /* characters */
  461.     ROM_LOAD( "821k07.k19", 0x040000, 0x040000, 0x060019fa )
  462.  
  463.     ROM_REGION( 0x100000, REGION_GFX2 ) /* graphics ( don't dispose as the program can read them ) */
  464.     ROM_LOAD( "821k04.k2",  0x000000, 0x080000, 0x00e0291b )    /* sprites */
  465.     ROM_LOAD( "821k05.k8",  0x080000, 0x080000, 0xe09ea05d )
  466.  
  467.     ROM_REGION( 0x0100, REGION_PROMS )
  468.     ROM_LOAD( "821a08.i15", 0x0000, 0x0100, 0x7da55800 )    /* priority encoder (not used) */
  469.  
  470.     ROM_REGION( 0x40000, REGION_SOUND1 )    /* data for the 007232 */
  471.     ROM_LOAD( "821k03.e5",  0x00000, 0x40000, 0xfef8505a )
  472. ROM_END
  473.  
  474. ROM_START( crimfgtj )
  475.     ROM_REGION( 0x28000, REGION_CPU1 ) /* code + banked roms */
  476.     ROM_LOAD( "821p02.bin", 0x10000, 0x18000, 0xf33fa2e1 )
  477.     ROM_CONTINUE(           0x08000, 0x08000 )
  478.  
  479.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the sound CPU */
  480.     ROM_LOAD( "821l01.h4",  0x0000, 0x8000, 0x0faca89e )
  481.  
  482.     ROM_REGION( 0x080000, REGION_GFX1 ) /* graphics ( don't dispose as the program can read them ) */
  483.     ROM_LOAD( "821k06.k13", 0x000000, 0x040000, 0xa1eadb24 )    /* characters */
  484.     ROM_LOAD( "821k07.k19", 0x040000, 0x040000, 0x060019fa )
  485.  
  486.     ROM_REGION( 0x100000, REGION_GFX2 ) /* graphics ( don't dispose as the program can read them ) */
  487.     ROM_LOAD( "821k04.k2",  0x000000, 0x080000, 0x00e0291b )    /* sprites */
  488.     ROM_LOAD( "821k05.k8",  0x080000, 0x080000, 0xe09ea05d )
  489.  
  490.     ROM_REGION( 0x0100, REGION_PROMS )
  491.     ROM_LOAD( "821a08.i15", 0x0000, 0x0100, 0x7da55800 )    /* priority encoder (not used) */
  492.  
  493.     ROM_REGION( 0x40000, REGION_SOUND1 )    /* data for the 007232 */
  494.     ROM_LOAD( "821k03.e5",  0x00000, 0x40000, 0xfef8505a )
  495. ROM_END
  496.  
  497. ROM_START( crimfgt2 )
  498. ROM_REGION( 0x28000, REGION_CPU1 ) /* code + banked roms */
  499.     ROM_LOAD( "crimefb.r02", 0x10000, 0x18000, 0x4ecdd923 )
  500.     ROM_CONTINUE(           0x08000, 0x08000 )
  501.  
  502.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the sound CPU */
  503.     ROM_LOAD( "821l01.h4",  0x0000, 0x8000, 0x0faca89e )
  504.  
  505.     ROM_REGION( 0x080000, REGION_GFX1 ) /* graphics ( don't dispose as the program can read them ) */
  506.     ROM_LOAD( "821k06.k13", 0x000000, 0x040000, 0xa1eadb24 )    /* characters */
  507.     ROM_LOAD( "821k07.k19", 0x040000, 0x040000, 0x060019fa )
  508.  
  509.     ROM_REGION( 0x100000, REGION_GFX2 ) /* graphics ( don't dispose as the program can read them ) */
  510.     ROM_LOAD( "821k04.k2",  0x000000, 0x080000, 0x00e0291b )    /* sprites */
  511.     ROM_LOAD( "821k05.k8",  0x080000, 0x080000, 0xe09ea05d )
  512.  
  513.     ROM_REGION( 0x0100, REGION_PROMS )
  514.     ROM_LOAD( "821a08.i15", 0x0000, 0x0100, 0x7da55800 )    /* priority encoder (not used) */
  515.  
  516.     ROM_REGION( 0x40000, REGION_SOUND1 )    /* data for the 007232 */
  517.     ROM_LOAD( "821k03.e5",  0x00000, 0x40000, 0xfef8505a )
  518. ROM_END
  519.  
  520. /***************************************************************************
  521.  
  522.   Game driver(s)
  523.  
  524. ***************************************************************************/
  525.  
  526. static void crimfght_banking( int lines )
  527. {
  528.     unsigned char *RAM = memory_region(REGION_CPU1);
  529.     int offs = 0;
  530.  
  531.     /* bit 5 = select work RAM or palette */
  532.     if (lines & 0x20){
  533.         cpu_setbankhandler_r (1, paletteram_r);                            /* palette */
  534.         cpu_setbankhandler_w (1, paletteram_xBBBBBGGGGGRRRRR_swap_w);    /* palette */
  535.     }
  536.     else{
  537.         cpu_setbankhandler_r (1, MRA_RAM);                                /* RAM */
  538.         cpu_setbankhandler_w (1, MWA_RAM);                                /* RAM */
  539.     }
  540.  
  541.     /* bit 6 = enable char ROM reading through the video RAM */
  542.     K052109_set_RMRD_line((lines & 0x40) ? ASSERT_LINE : CLEAR_LINE);
  543.  
  544.     offs = 0x10000 + ( ( lines & 0x0f ) * 0x2000 );
  545.     cpu_setbank( 2, &RAM[offs] );
  546. }
  547.  
  548. static void crimfght_init_machine( void )
  549. {
  550.     unsigned char *RAM = memory_region(REGION_CPU1);
  551.  
  552.     konami_cpu_setlines_callback = crimfght_banking;
  553.  
  554.     /* init the default bank */
  555.     cpu_setbank( 2, &RAM[0x10000] );
  556. }
  557.  
  558. static void init_crimfght(void)
  559. {
  560.     konami_rom_deinterleave_2(REGION_GFX1);
  561.     konami_rom_deinterleave_2(REGION_GFX2);
  562. }
  563.  
  564.  
  565.  
  566. GAME( 1989, crimfght, 0,        crimfght, crimfght, crimfght, ROT0, "Konami", "Crime Fighters (US 4 players)" )
  567. GAME( 1989, crimfgt2, crimfght, crimfght, crimfgtj, crimfght, ROT0, "Konami", "Crime Fighters (World 2 Players)" )
  568. GAME( 1989, crimfgtj, crimfght, crimfght, crimfgtj, crimfght, ROT0, "Konami", "Crime Fighters (Japan 2 Players)" )
  569.